package algo_lignes_sites.data.path;

import algo_lignes_sites.data.junction.A_Junction;
import algo_lignes_sites.data.junction.JunctionREF;
import algo_lignes_sites.data.segment.SegmentREF;
import algo_lignes_sites.params.objects.contraintesgeom.ContrainteGeomLine;
import commons.data.Attributes;
import commons.data.EchelleGeneralization;
import commons.data.Zones;
import java.awt.Color;
import java.util.ArrayList;

public class PathREF extends A_Path {

	public ArrayList<JunctionREF> vJunctionREF;
	@Override
	public ArrayList getVJunction() {return vJunctionREF;}
	public ArrayList<JunctionREF> getVJunctionREF() {return vJunctionREF;}
	public void setVJunctionREF(ArrayList<JunctionREF> vJunctionREF) {this.vJunctionREF = vJunctionREF;}

	private ArrayList<SegmentREF> vSegmentREF;
	@Override
	public ArrayList getVSegment() {return vSegmentREF;}
	public ArrayList<SegmentREF> getVSegmentREF() {return vSegmentREF;}


	protected PathDER pathDER;
	public PathDER getPathDER() {return pathDER;}
	public void setPathDER(PathDER pathDER) {this.pathDER = pathDER;}

	// permet de tracer si un path a déjà été coupé une premiere fois 
	private boolean bHasBeenCutDuringSimplifNode = false;
	public void setIsCutDuringSimplifNode() {bHasBeenCutDuringSimplifNode = true;}
	public boolean hasBeenCutDuringSimplifNode() {return bHasBeenCutDuringSimplifNode;}


	public PathREF (Attributes attributes, Zones zones, ContrainteGeomLine cgl, EchelleGeneralization eg, Color color) {
		super(attributes, zones, cgl, eg, color);
		vJunctionREF = new ArrayList<JunctionREF>();
	}
	
	// Data appelle une seule fois cette méthode, puisque les segments pointent dynamiquement sur les junctions
	// Seuls les angles des segments seront à recalculer (par Data_ls) à chaque itération
	@Override
	public void computeVSegment() {
		ArrayList<A_Junction> vJunction = getVJunction();
		int nbJunction = vJunction.size();

		vSegmentREF = new ArrayList<SegmentREF>(nbJunction-1);

		A_Junction j1, j2;
		j2 = vJunction.get(0);
		for (int i=0; i<nbJunction-1; i++) {
			j1 = j2;
			j2 = vJunction.get(i+1);
			vSegmentREF.add(new SegmentREF(this, j1, j2));
		}
	}
	

}
